#include "search/search_server.hpp"
#include <iostream>

// 运行在线服务器
void runOnlineServer() {
    const std::string ip = "0.0.0.0"; // 监听所有网络接口
    const uint16_t port = 8888;
    const int threadNum = 4; // IO 线程数量
    
    SearchServer server(ip, port, threadNum);
    std::cout << "正在初始化服务器..." << std::endl;

    // 请确保这些文件路径是正确的
    bool success = server.init(
        "resources/dict/cn_dict.txt", "resources/index/cn_index.txt",
        "resources/dict/en_dict.txt", "resources/index/en_index.txt",
        "resources/data/inverted_index.lib", "resources/data/pages.lib", "resources/data/offsets.lib"
    );

    if (!success) {
        std::cerr << "服务器初始化失败！请检查数据文件路径。" << std::endl;
        return;
    }
    
    server.start(); // 启动服务
}

int main(int argc, char* argv[]) {
    // 这里我们只关注启动在线服务
    runOnlineServer();
    return 0;
}
